home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / pd / daten / xmgr / examples / tmc.c < prev    next >
C/C++ Source or Header  |  1995-02-05  |  2KB  |  67 lines

  1. /*
  2.  * test of -pipe option
  3.  */
  4. #include <stdio.h>
  5. #include <math.h>
  6.  
  7. #ifndef M_PI
  8. #define M_PI 3.14
  9. #endif
  10.  
  11. main(argc, argv)
  12.     int argc;
  13.     char **argv;
  14. {
  15.     int i, j;
  16.     double x, y, t, dt;
  17.  
  18.     for (j = 20; j > 0; j--) {
  19.  
  20.     /*
  21.      * write out a set
  22.      */
  23.     for (i = 0; i < 101; i++) {
  24.         t = 8.0 * i / (1.0 * j) * M_PI;
  25.         printf("%d %lf\n", i, cos(t) + sin(2.0 * t) + cos(t / 2.0) + sin(4 * t) + cos(t / 4.0));
  26.     }
  27.  
  28.     printf("&\n");        /* end of set marker */
  29.  
  30.     /*
  31.      * if this is the first set (j == 10) then autoscale.
  32.      */
  33.     if (j == 20) {
  34.         printf("@view 0.1, 0.1, 0.9, 0.4\n"); /* set the viewport for this graph */
  35.         printf("@with g1\n");        /* reset the current graph to graph 1 */
  36.         printf("@view 0.1, 0.5, 0.9, 0.9\n"); /* set the viewport for graph 1 */
  37.         printf("@with g0\n");        /* reset the current graph to graph 0 */
  38.         printf("@autoscale\n");         /* autoscale the first time through */
  39.         printf("@focus off\n");         /* turn of the focus markers (annoying) */
  40.         printf("@dft(s0, 2)\n");         /* compute the spectrum of the first set */
  41.         printf("@move g0.s1 to g1.s0\n");     /* move the computed spectrum to graph 1 */
  42.         printf("@with g1\n");        /* set the focus on graph 1 */
  43.         printf("@autoscale\n");        /* autoscale graph 1 */
  44.         printf("@subtitle \"Spectrum\"\n"); /* set the subtitle */
  45.         printf("@with g0\n");        /* reset the current graph to graph 0 */
  46.         printf("@subtitle \"Data %d\"\n", j);/* set the subtitle for graph 0 */
  47.         printf("@kill s0\n");        /* don't need it so kill it (data will be read into
  48.                            this set */
  49.         printf("@sleep 2\n");
  50.     }
  51.     /*
  52.      * else just redraw the plot
  53.      */
  54.     else {
  55.         printf("@dft(s0, 2)\n");         /* spectrum */
  56.         printf("@move g0.s1 to g1.s0\n");     /* move it to graph 1 */
  57.         printf("@subtitle \"Data %d\"\n", j);/* set the subtitle for graph 0 */
  58.         printf("@redraw\n");         /* redraw the graph with the same scaling limits */
  59.         printf("@kill s0\n");         /* kill set 0 in graph 0 */
  60.         printf("@with g1\n");         /* switch to graph 1 */
  61.         printf("@kill s0\n");         /* kill set 0 in graph 1 */
  62.         printf("@with g0\n");         /* reset the current graph to graph 0 */
  63.         printf("@sleep 1\n");        /* let the graph sit for a sec */
  64.     }            /* end if-else */
  65.     }                /* end for */
  66. }
  67.